package datamodels;

import java.util.ArrayList;
import java.util.List;
/**
 * Design: Thank to GROUP 5
 * A manuscript class. Containing a list of reviews submitted reviewers
 * the content of the manuscript and its author.  
 * 
 * @author Rithy Chhen
 * @version 11.15.2011
 */
public class Manuscript {
	/**
	 * a list of review in each manuscript
	 */
	private List<Review> my_review;
	/**
	 * the author of the manuscript.
	 */
	private User my_author; 
	/**
	 * the content of the manuscript.
	 */
	private String my_text; 
	/** the manuscript title. */
	private String my_title;
	/** the status of the manuscript */
	private Status my_status; 
	/**
	 * constructor. 
	 * @param the_user the user. 
	 * @param the_text the content.
	 */
	public Manuscript(User the_user, String the_text) {
		my_status = Status.UNDECIDED;
		my_author = the_user;
		my_text = the_text;
		my_review = new ArrayList<Review>();
	}

	/**constructor*/
	public Manuscript() {
		my_review = new ArrayList<Review>();
	}
	/**set the status of a manuscript*/
	public void setCurrentStatus(Status the_status) {
		my_status = the_status;
	}
	/** get the current status of a manuscript */
	public Status getCurrentStatus() {
		return my_status;
	}

	/**
	 * set title. 
	 * @pre the_title != NULL. 
	 * @post my_title = the_title.
	 */
	public void setTitle(String the_title) {
		my_title = the_title;
	}
	/**get the title.*/
	public String getTitle() {
		return my_title;
	}
	/**
	 * get reviews
	 * precondition: size <= 0
	 * 
	 * @return a list of review in this manuscript.
	 */
	public List<Review> getReviews() {
		return my_review;
	}
	/**
	 * set the author of this manuscript.
	 * @param the_author the author to be set.
	 */
	public void setAuthor(final User the_author)
	{
		my_author = the_author;
	}
	/**
	 * get athor. 
	 * precondition: there is an author.
	 * @return a author of this manuscript.
	 */
	public User getAuthor()
	{
		return my_author;
	}
	/**
	 * set text.
	 */
	public void setText(String the_text) {
		my_text = the_text;
	}
	/**
	 * get text. 
	 * precondition: text != NULL
	 * 
	 * @return a content of this manuscript.
	 */
	public String getText() {
		return my_text;
	}
	
	/**
	 * Add a review to the manuscript.
	 * 
	 * @param the_review
	 * @pre the_review != NULL and the_review is a Review.
	 * @post this Manuscript has a reference to the_review.
	 */
	public void addReview(Review the_review)
	{
		my_review.add(the_review);
	}
	public boolean equals(Manuscript the_manuscript)
	{
		boolean same = false;
		int correct = 0;
		if (my_review.equals(the_manuscript.getReviews()))
		{
			correct++;
		}
		if (my_author.equals(the_manuscript.getAuthor()))
		{
			correct++;
		}
		if (my_text.equals(the_manuscript.getText()))
		{
			correct++;
		}
		if (correct == 3)
		{
			same = true;
		}
		return same;
	}
}
